package middlecontent.code;

public class SonTest {
    public static void main(String[] args) {
        Father f = new Son();
        System.out.println(f.x);
    }


}

class Father{
    int x = 10;
    public Father(){
        this.print();
        x = 20;
    }
    public void print(){
        System.out.println(x);
    }

}

/**
 * 属性不存在多态性
 */
class Son extends Father{
    int x = 30;

    /**
     * 执行顺序：初始赋值，调用父构造器，子类赋值，执行子类构造器中的代码
     */
    public Son(){
        this.print();
        x = 40;
    }
    public void print(){
        System.out.println(x);
    }

}